
<%--
 *  File:    ConsumerManagement.jsp
 *  @Author: DC
 *  Date:    2011/09/13
 *
 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%
  //init param
  String strTableName = "v_zylconsumermanagement";
  String strModuleName = "CRM";
  String privilegeCode = "10300";
  String contextPath = request.getContextPath(); 
  //System.out.println("*********************"+privilegeCode);
  //System.out.println("22222222222222");
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>VisitProcessSummary</title>
<PageFlow:CheckPageFlow pageName="p_consumersummary"/>
<%
	String isNew = "";
	String isDefault = "";
	String paraIsDefault = "";
	//System.out.println("Trace \"isdefault\" ------- summary" + ((String)pageContext.getAttribute("isdefault")));
	if("Y".equals(((String)pageContext.getAttribute("isdefault")))||"Y".equals(request.getParameter("isdefault"))) {
		isDefault = "&isdefault=Y";
		paraIsDefault="Y";
	}else if("N".equals(((String)pageContext.getAttribute("isdefault")))||"Y".equals(request.getParameter("isdefault"))) {
		isDefault = "&isdefault=N";
		paraIsDefault="N";
	}
%>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<script language="JavaScript" src="../../js/keyFunction.js"></script>
<script language="JavaScript" src="../../js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>
<script language="JavaScript" src="../../js/SummaryDivision.js"></script>

<%
HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
Integer employeeid=(Integer)CurUserInfo.get("userid");
String  isadmin=(String)CurUserInfo.get("isadmin");
if(isadmin==null) isadmin="";
%>
<script language="JavaScript">


function clickRow(id,status)
{
  document.frm.zylconsumermanagementid.value = id;

  document.frm.status.value = status;
}
function page_new()
{
	<%isNew = "&isNew=Y";%>
   location.href="ConsumerFrm.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%><%=JspHelper.filterNull(isNew)%>";
}
function page_delete()
{	if(isEmpty(document.frm.zylconsumermanagementid.value) || document.frm.zylconsumermanagementid.value == -1)
	{
		return;
	}
	if(10!=document.frm.status.value){
		alert("<%= message.getMessageDesc("CAN_NOT_DELETE_BY_STATUS10") %>");
		return false;
		
	}
	if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>") )  return;

	
	
	document.frm.actionname.value="delete";
	document.frm.submit();
}
function page_edit()
{
	
  var id = document.frm.zmylagreementid.value;
  
  var editurl;

  if(id == null || id.length == 0 || id == "" || id == "-1")
  {
    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
    return;
  }  
  if(10!=document.frm.status.value){
		alert("<%= message.getMessageDesc("CAN_NOT_MODIFY_BY_STATUS10") %>");
		return false;
		
	}
	<%isNew = "&isNew=N";%>
    
	editurl = "AgreementFrm.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%>&zmylagreementid=" + id + "&languagecode=" + "<%= strLanguageCode %><%=JspHelper.filterNull(isNew)%>";
	
    self.location.href = editurl;
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(frm,actionvalue,orderbyname);
  editform.action = "ConsumerManagement.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%>&languagecode=<%= strLanguageCode %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}

function page_popBusinessarea()
{
  if (typeof popwindow != 'undefined') popwindow.close();

  popwindow = window.open("<%=contextPath%>/masterdata/ogm/zylstdbusinessareapop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}

function setContact(id,type,name){
	document.getElementById("stdareaid").value=id;
	document.getElementById("strareaname").value=name;
}


 function popRep() {
		
	 if (typeof popwindow != 'undefined') popwindow.close();
	  popwindow = window.open("<%=contextPath%>/zyl/masterdata/analysislist/EmployeeBussise.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	  }

 function SetSalesMan(employeecode,employeename){
	 
		document.getElementById("employeecode").value=employeecode;
		document.getElementById("employeename").value=employeename;
	}

 function page_clear(){
		document.getElementById("consumercode").value="";
		document.getElementById("consumername").value="";
		document.getElementById("employeecode").value="";
		document.getElementById("employeename").value="";
	    //document.getElementById("deptid").options[0].selected=true;
		//document.getElementById("batchnosearch").value="";
		document.getElementById("strareaname").value="";
		document.getElementById("businessareaname").value="";

	}


 function popAreaNew(num){
		if(popwindow!=null) popwindow.close();
		if(num != null || num == ''){
			document.frm.currentnum.value=num;
	 	}else{
	 	 	document.frm.currentnum.value='';
	 	}

		var currentnum = document.frm.currentnum.value;
		//var flag=document.cform.flag.value;
	 	//var deptid = document.cform['deptid'+currentnum].value;
	    url = '../../masterdata/map/AreaPopNewWindow.jsp?<%= OvalTools.randomURL() %>';
	    attribute = 'height=300, width=500,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';

		popwindow = window.open(url,'newwindow', attribute);
	}

	function SetAreaPopMoulty(areaids,areacodes,areanames){
		//document.frm.areaids.value = areaids;
		document.frm.businessareacode.value = areacodes;
		document.frm.businessareaname.value = areanames;
	}
  function	page_report(){

	  var stdareaid=document.frm.stdareaid.value; 
	  var consumercode=document.frm.consumercode.value; 
	  var consumername=document.frm.consumername.value; 
	  var employeecode=document.frm.employeecode.value; 
	  var employeename=document.frm.employeename.value; 
	  var businessareaname=document.frm.businessareaname.value; 
	  //var stdareaid=document.frm.stdareaid.value; 
	  
	  if(!isEmpty(stdareaid)){
		  <%if("Y".equals(isadmin)){%>
		  window.open("<%= reportURL %>/servlet/ExcecuteReport/zylconsumermanager.sox?__format=xlsx&__folder=/ovalreport&employeeid="+<%=employeeid %>+"&stdareaid="+stdareaid+"&consumercode="+consumercode+"&consumername="+escape(encodeURI(consumername))+"&employeecode="+employeecode+"&employeename="+escape(encodeURI(employeename))+"&businessareaname="+escape(encodeURI(businessareaname)));
		  <%}else{%>
		  window.open("<%= reportURL %>/servlet/ExcecuteReport/zylconsumermanager.sox?__format=xlsx&__folder=/ovalreport&stdareaid="+stdareaid+"&consumercode="+consumercode+"&consumername="+escape(encodeURI(consumername))+"&employeecode="+employeecode+"&employeename="+escape(encodeURI(employeename))+"&businessareaname="+escape(encodeURI(businessareaname)));
		  <%}%>
		  }else{
			  alert("<%= message.getMessageDesc("STDAREA_NOT_NULL")%>");
			  }
	  }
  function page_reportcsv(){

	  //window.open("<%= reportURL %>/csv?__report=/ovalreport/zylconsumermanager.txt");


	  var stdareaid=document.frm.stdareaid.value; 
	  var consumercode=document.frm.consumercode.value; 
	  var consumername=document.frm.consumername.value; 
	  var employeecode=document.frm.employeecode.value; 
	  var employeename=document.frm.employeename.value; 
	  var businessareaname=document.frm.businessareaname.value; 
	  //var stdareaid=document.frm.stdareaid.value; 
	  
	  //if(!isEmpty(stdareaid)){
		  <%if("Y".equals(isadmin)){%>

		  window.open("<%= reportURL %>/csv?__report=/ovalreport/zylconsumermanager.txt&employeeid="+<%=employeeid %>+"&stdareaid="+stdareaid+"&consumercode="+consumercode+"&consumername="+escape(encodeURI(consumername))+"&employeecode="+employeecode+"&employeename="+escape(encodeURI(employeename))+"&businessareaname="+escape(encodeURI(businessareaname)));
		  <%}else{%>

		  window.open("<%= reportURL %>/csv?__report=/ovalreport/zylconsumermanager.txt&stdareaid="+stdareaid+"&consumercode="+consumercode+"&consumername="+escape(encodeURI(consumername))+"&employeecode="+employeecode+"&employeename="+escape(encodeURI(employeename))+"&businessareaname="+escape(encodeURI(businessareaname)));

		 
		  <%}%>
		 // }else{
			  //alert("<%= message.getMessageDesc("STDAREA_NOT_NULL")%>");
			 // }
  }
</script>
</head>
<body>

<form name="frm" method="post" action="../../Dispatcher">
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
   
      <input type="hidden" name="pagename" value="p_consumersummary">
      <input type="hidden" name="currentnum">
      <input type="hidden" name="actionname">   
      <input type="hidden" name="isdefault" value="<%= paraIsDefault %>">   
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0">
        <tr> 
          <td class="summary_top" colspan="3" ></td>
        </tr>
        <tr>
          <td>    
	 <table border="0" cellspacing="0">    
            <%--@ include file="/inc/SummarySearch.inc" --%>  
            
      <tr> 
    	<td valign="top"> 
    		<table width="100%" border="0" cellspacing="0">
          	<tr><td class="summary_top" ></td></tr>
          	<tr>
				
          	    <td style="text-align:right"><%= label.getLabelName("L_Consumer")+label.getLabelName("L_Code") + label.getLabelName("L_Colon") %></td>
          	    <td><custom:text property="consumercode"/></td>
          	    
				<td style="text-align:right"><%= label.getLabelName("L_Consumer")+label.getLabelName("L_OnceCustomerName") %></td>
				<td><custom:text property="consumername"/></td>
				
				<td style="text-align:right"><%= label.getLabelName("L_Employeecode ") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="employeecode"/></td>
				
				<td style="text-align:right"><%= label.getLabelName("L_Delegacy") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="employeename"/>
				<a onclick="popRep();"><custom:button type="3" value="*"/></a></td>
				
				<td style="text-align:right"><%= label.getLabelName("L_RegionOffice") + label.getLabelName("L_Colon") %></td>
				<td style="text-align:right"><custom:hidden property="businessareacode" /><custom:text property="businessareaname" />
				<!--  <a onclick="popAreaNew();"><custom:button type="3" value="*"/></a></td>-->
				
				</tr>
				<tr>
				
				<td style="text-align:right"><%= label.getLabelName("L_Provicetdr") + label.getLabelName("L_Colon") %></td>
				<td style="text-align:right"><custom:hidden property="stdareaid" /><custom:text property="strareaname"/>
				<a onclick="page_popBusinessarea();"><custom:button type="3" value="*"/></a></td>
				
				<td colspan="2"><a href="javascript:page_summary('search')"><img src="/oval/images/cn/go_fy.gif" border="0" style="border: 1 solid #000000"></a>&nbsp;&nbsp;<button button type="button" onclick="page_clear()" class="button1" name="re" value="clear"><%= label.getLabelName("L_Clear") %></button></td>
          	</tr>
        	</table>
        </td>
   	</tr>
  </table>
            
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td> 
      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">
          <tr class="deepblue-left">
			<td  rowspan="2" class="title_center">&nbsp;</td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_Consumer")+label.getLabelName("L_Code")%></td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_Consumer")+label.getLabelName("L_OnceCustomerName")%></td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_Gender")%></td>
            
             <td  rowspan="2" class="title_center"><%= label.getLabelName("L_VipNo")%></td>

            <td  colspan="3" class="title_center"><%= label.getLabelName("L_PostalAddress ")%></td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_ContactMethod")%></td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_Occupation")+label.getLabelName("L_Name") %></td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_Employeecode ") %></td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_Responsibility") %></td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_RegionOffice")%></td>
            <td  rowspan="2" class="title_center"><%= label.getLabelName("L_Provicetdr") %></td>
		</tr>
		<tr class="deepblue-left">
    			   <td class="title_center">所属省</td>
                   <td class="title_center">所属市</td>
				   <td class="title_center">所属县区</td>
		</tr>
          <%
             Vector consumersummary1 = (Vector)pageContext.getAttribute("consumersummary");
             if(consumersummary1 == null)
             {
            	 consumersummary1 = new Vector();
             }
             
             System.out.println(consumersummary1.size());
             String strClassType = new String("");   
             Integer nDefaultId = null;             
             Integer nDefaultStatus = null;
             Integer nDefaultVersion = new Integer(-1);
             int i=0;
             String strChecked = "";
             boolean bHasChecked = false;
          %>   
          <logic:iterate id="consumers" collection="<%= consumersummary1 %>">
          <%
            if(i%2 == 1)
            {
              strClassType = "td-listrom";
            }else{                    
              strClassType = "none";
            }
            if(!bHasChecked)
            {
              nDefaultId = (Integer)((HashMap)pageContext.getAttribute("consumers")).get("zylconsumermanagementid");
             nDefaultStatus = (Integer)((HashMap)pageContext.getAttribute("consumers")).get("status");
            //  System.out.println("--nDefaultId--" + nDefaultId);
              
              bHasChecked = true;
              strChecked = "Checked";
            }
            else
            {
              strChecked = "";
            }
            i++;
          %>            
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="radiotrue('zylconsumermanagementid<%=JspHelper.filterNull( i )%>');
			    javascript:clickRow('<oval:write name="consumers" property="zylconsumermanagementid" />',
			                        '<oval:write name="consumers" property="status" />');"
          class="<%=JspHelper.filterNull( strClassType )%>"> 
            <td> 
              <input <%=JspHelper.filterNull( strChecked )%> id="zylconsumermanagementid<%=JspHelper.filterNull( i )%>" type="radio" name="order" value="<oval:write name="consumers" property="zylconsumermanagementid"/>" class="normalradio"/>
            </td>       
            <td class="hand"><a href="ConsumerFrm.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%>&viewflag=view&zylconsumermanagementid=<custom:write name="consumers" property="zylconsumermanagementid"/>"><custom:write name="consumers" property="consumercode" nbsp="true"/></a></td>
           <td><custom:write name="consumers" property="consumername" nbsp="true"/></td>
            <td><custom:write name="consumers" property="gendername" nbsp="true"/></td>
            <td><custom:write name="consumers" property="membercardnumber" nbsp="true"/></td>
            <td><custom:write name="consumers" property="regionname" nbsp="true"/></td>
			<td><custom:write name="consumers" property="cityname" nbsp="true"/></td>
			<td><custom:write name="consumers" property="countyname" nbsp="true"/></td>
            <td><custom:write name="consumers" property="telephone" nbsp="true"/></td>
			<td><custom:write name="consumers" property="jobname" nbsp="true"/></td>
			<td><custom:write name="consumers" property="employeecode" nbsp="true"/></td>
            <td><custom:write name="consumers" property="employeename" nbsp="true"/></td>
			<td><custom:write name="consumers" property="areaname" nbsp="true"/></td>
			<td><custom:write name="consumers" property="area2name" nbsp="true"/></td>

			
          </tr>
          </logic:iterate> 
        <%
            String history=(String)pageContext.getAttribute("history");
        %> 
        <input type="hidden" name="zylconsumermanagementid" value="<%=JspHelper.filterNull( nDefaultId )%>">
         <input type="hidden" name="status" value="<%=JspHelper.filterNull( nDefaultStatus )%>">
        <%--<input type="hidden" name="history" value="<custom:write property="history"/>"/> --%>
        <%@ include file="/inc/SummaryAction.inc" %>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top" ></td>
        </tr>
        <tr>
        
          <td class="td_center">
           <%--if(history==null||history.trim().equals("")){%>
              <a onclick="page_new()"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
              
              <%if(pageContext.getAttribute("consumersummary")!=null){%>

              <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
              
              <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
              <%}%>
           <%}else{%>
           <a onclick="page_back()"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>
          <%}--%>
          <a onclick="page_reportcsv()"><custom:button type="1" label="L_ExportCSV" imgsrc="edit.gif" border="0" style="width:70" privilegeCode="MB-XFZ01"/></a>
          <a onclick="page_report()"><custom:button type="1" label="L_Upload_Derived" imgsrc="edit.gif" border="0" style="width:70" privilegeCode="MB-XFZ02"/></a>
        
          </td>
        </tr>
      </table>
    </td>
  </tr>

</table>
 </form>
</body>
</html>
